package com.cskaoyan.day31.work1._04_proxy._01_static_proxy;

import com.cskaoyan.day31.work1._04_proxy._00_bean.BuyFood;
import com.cskaoyan.day31.work1._04_proxy._00_bean.Study;
import com.cskaoyan.day31.work1._04_proxy._00_bean.User;

public class UserProxy implements BuyFood, Study {

    User user;
    public void setUser(User user){
        this.user = user;
    }
    @Override
    public void buyBreakfast(String name) {
        long startTime = System.currentTimeMillis();
        this.user.buyBreakfast(name);
        long endTime = System.currentTimeMillis();
        long cost = endTime - startTime;
        System.out.println("购买 " + name + "花费的时间为："+cost);

    }

    @Override
    public void buyLunch(String name) {
        long startTime = System.currentTimeMillis();
        this.user.buyLunch(name);
        long endTime = System.currentTimeMillis();
        long cost = endTime - startTime;
        System.out.println("购买 " + name + "花费的时间为："+cost);
    }

    @Override
    public void buyDinner(String name) {
        this.user.buyDinner(name);
        System.out.println("购买可乐");
    }

    @Override
    public String study(String name1, String name2) {
        String study = this.user.study(name1, name2);
        System.out.println("购买可乐");
        return study;
    }
}
